function init(){
    ajaxCall("POST",path+"/HistoryMyGroupServlet?method=getTable",insertTable);
    ajaxCall("GET",path+"/GroupServlet?method=getGroupIdByName",setGroupId);
}
function insertTable(res) {
    var obj=JSON.parse(res);
    var table=document.getElementById("t1");
    for(var i in obj) {
        insertIntoTable(obj[i].date, obj[i].question,obj[i].score);
    }
}
function setGroupId(res){
    var obj=JSON.parse(res);
    document.getElementById("groupId").innerText=obj;
}

function insertIntoTable(cell1,cell2,cell3){
    var table=document.getElementById("t1");
    var newRow=table.insertRow(1);

    var date=newRow.insertCell(0);
    var question=newRow.insertCell(1);
    var score=newRow.insertCell(2);
    var details=newRow.insertCell(3);
    date.innerHTML=cell1;
    question.innerHTML=cell2;
    if(cell3=="0"){
        score.innerHTML="未批改";
    }
    else {
        score.innerHTML = cell3;
    }
    details.innerHTML="<input type='button' value='详情' onclick='showDetils(this)'/>";
}
function showDetils(row) {
    var rowIndex=row.parentNode.parentNode.rowIndex;
    var table=document.getElementById("t1");
    var Dtime=table.rows[rowIndex].cells[0].innerHTML;
    var score=table.rows[rowIndex].cells[2].innerHTML;
    var groupId=document.getElementById("groupId").innerText;
    window.location.href="selfHistoryGroup_detiles.jsp?Dtime="+Dtime+"&groupId="+groupId+"&score="+score;
}
